//
//  ViewController.m
//  CloudPlayerDemo
//
//  Created by Ru He on 2022/2/25.
//

#import "ViewController.h"
#import "PlayerViewController.h"
#import "MultiPlayerViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UITextField *inputTextField;
@property (weak, nonatomic) IBOutlet UITextField *typeTextField;
@property (weak, nonatomic) IBOutlet UITextField *urlTextField1;
@property (weak, nonatomic) IBOutlet UITextField *urlTextField2;
@property (weak, nonatomic) IBOutlet UITextField *urlTextField3;
@property (weak, nonatomic) IBOutlet UITextField *urlTextField4;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.hidden = YES;
    
    self.view.userInteractionEnabled  = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapView:)];
    [self.view addGestureRecognizer:tap];
}

- (IBAction)play:(id)sender {
    
    [self.view endEditing:YES];
    PlayerInfo *playerInfo = [[PlayerInfo alloc] init];
    playerInfo.mediaUrl = self.inputTextField.text;
    playerInfo.mediaType = (HCPMediaType)[self.typeTextField.text intValue];
    
    PlayerViewController *vc = [[PlayerViewController alloc] init];
    vc.playerInfo = playerInfo;
    
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)multiPlay:(id)sender {
    
    PlayerInfo *info1 = [[PlayerInfo alloc] init];
    info1.mediaUrl = _urlTextField1.text;
    info1.mediaType = MEDIA_TYPE_VOD;
    
    PlayerInfo *info2 = [[PlayerInfo alloc] init];
    info2.mediaUrl = _urlTextField2.text;
    info2.mediaType = MEDIA_TYPE_VOD;
    
    PlayerInfo *info3 = [[PlayerInfo alloc] init];
    info3.mediaUrl = _urlTextField3.text;
    info3.mediaType = MEDIA_TYPE_VOD;
    
    PlayerInfo *info4 = [[PlayerInfo alloc] init];
    info4.mediaUrl = _urlTextField4.text;
    info4.mediaType = MEDIA_TYPE_VOD;
    
    NSArray *array = @[info1, info2, info3, info4];
    
    MultiPlayerViewController *vc = [[MultiPlayerViewController alloc] init];
    vc.dataArray = array;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)tapView:(UITapGestureRecognizer *)tap {
    [self.view endEditing:YES];
}

@end
